// #include <buola/gui/cwindow.h>
// #include <buola/cv/coctreeview.h>
// #include <buola/app/ceventloop.h>
// #include <buola/cv/coccupancyoctree.h>
// #include <buola/cv/ccloud.h>
// #include <buola/cv/ccloudview.h>
// #include <buola/mat.h>
// #include <buola/mat/cgaussianprocess.h>

//using namespace buola;

int main(int pNArg,char **pArgs)
{
#if 0
    buola_init(pNArg,pArgs);

    try
    {
        cvi::COccupancyOcTree lTree(0.25);

        start_timer();
        auto lCloud=cvi::load_cloud(io::get_home()/"gazebo.tif",io::get_home()/"gazebo.ppm",io::get_home()/"gazebo.info");
        end_timer();

        start_timer();
        lTree.InsertCloud(lCloud);
        end_timer();

        mat::CMat_d lPoints(std::distance(lTree.begin(),lTree.end()),3);
        mat::CVec_d lValues(std::distance(lTree.begin(),lTree.end()));

        int r=0;
        for(auto i=lTree.begin();i!=lTree.end();i++)
        {
            lPoints(r,0)=i.Coords().x();
            lPoints(r,1)=i.Coords().y();
            lPoints(r,2)=i.Coords().z();

            lValues[r]=i->Value();

            ++r;
        }

        msg_info() << "size of octree:" << r << "\n";
        
        msg_info() << "training gaussian process\n";
        mat::CGaussianProcess<double> lProcess(lPoints,lValues);
        msg_info() << "a\n";
        mat::CVec3d lCenter=center(lCloud);
        msg_info() << "b\n";
        mat::CVec3d lMin=min(lCloud);
        msg_info() << "c\n";
        mat::CVec3d lMax=max(lCloud);
        msg_info() << "d\n";

        cvi::CCloud_rgb8 lViewCloud;

        msg_info() << "estimating\n";
        for(double x=lMin.x();x<lMax.x();x+=0.1)
        {
            for(double y=lMin.y();y<lMax.y();y+=0.1)
            {
                for(double z=lMin.z();z<lMax.z();z+=0.1)
                {
                    double lValue=lProcess.F(mat::CVec_d({x,y,z}));
                    if(lValue>0.0)
                    {
                        unsigned char lPixel=(unsigned char)(std::min(lValue,1.0)*255);
                        cvi::CCloud_rgb8::TPoint lP;

                        lP.mPos=mat::CVec3d({x,y,z});

                        lP.mData[0]=lPixel;
                        lP.mData[1]=lPixel;
                        lP.mData[2]=lPixel;

                        lCloud.push_back(lP);
                    }
                }
            }
        }

        gui::CWindow lWindow;

        cvi::CCloudView lView;
        lView.SetCloud(std::move(lCloud));
        lView.SetCameraPos(lCenter-mat::CVec3d({30,0,0}));
        lWindow.Attach(&lView,gui::ATTACH_REPLACECLIENT);

        lWindow.Map();
        set_main_window(&lWindow);

        get_main_event_loop().Loop();
    }
    catch(std::exception &pE)
    {
        msg_info() << "caught exception " << pE.what() << "\n";
    }

    return buola_finish();
#endif
    
}
